package com.eirikb.shared.events;

import com.eirikb.client.Client;

/**
 *
 * @author eirikb
 */
public class NickChangeEvent extends Event {

    private String nick;
    private String newNick;

    public NickChangeEvent(String nick, String newNick) {
        this.nick = nick;
        this.newNick = newNick;
    }

    public void execute(Client client) {
        client.getChat().removeNick(nick);
        client.getChat().addNick(newNick);
        if (nick.equals(client.getNick())) {
            client.setNick(newNick);
        }
        client.getChat().addChat("* " + nick + " har byttet nick til " + newNick);
    }
}
